#
# Real Fort Mod
# ViSaRealFortEventManager
# 

from CvPythonExtensions import *
import CvUtil

import CvEventManager
import sys
import PyHelpers
import CvCameraControls
import RealFort
import CvConfigParser


gc = CyGlobalContext()	
doRealFort = RealFort.RealFort()
PyPlayer = PyHelpers.PyPlayer

def loadConfigurationData():

	global g_bPartisanEnable
	g_bPartisanEnable = False

	# loads the ViSa mod ini file
	config = CvConfigParser.CvConfigParser("ViSa_v3.ini")

	# If we actually were able to open the "ViSa_v3.ini" file then read in the values.
	# otherwise we'll keep the default values that were set at the top of this file.
	if(config != None):
		g_bPartisanEnable = config.getboolean("ViSa Component Control","Partisan allowed", False)

	
# globals
###################################################
class CvRealFortEventManager:
	def __init__(self, eventManager):
		# initialize base class

		loadConfigurationData()

		eventManager.addEventHandler("improvementBuilt", self.onImprovementBuilt)
		eventManager.addEventHandler("unitMove", self.onUnitMove)
		eventManager.addEventHandler("techAcquired", self.onTechAcquired)

		
	def onImprovementBuilt(self, argsList):
		if ( g_bPartisanEnable ):
			doRealFort.doImprovementBuilt(argsList)
		
	def onUnitMove(self, argsList):
		if ( g_bPartisanEnable ):
			doRealFort.doUnitMove(argsList)
		
	def onTechAcquired(self, argsList):
		if ( g_bPartisanEnable ):
			doRealFort.doTechAcquired(argsList)
